/****************************************************************************
*
*    Copyright (c) 2020 Vivante Corporation
*
*    Permission is hereby granted, free of charge, to any person obtaining a
*    copy of this software and associated documentation files (the "Software"),
*    to deal in the Software without restriction, including without limitation
*    the rights to use, copy, modify, merge, publish, distribute, sublicense,
*    and/or sell copies of the Software, and to permit persons to whom the
*    Software is furnished to do so, subject to the following conditions:
*
*    The above copyright notice and this permission notice shall be included in
*    all copies or substantial portions of the Software.
*
*    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
*    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
*    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
*    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
*    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
*    FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
*    DEALINGS IN THE SOFTWARE.
*
*****************************************************************************/


#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include "vsi_nn_types.h"
#include "vsi_nn_tensor.h"
#include "vsi_nn_graph.h"
#include "vsi_nn_log.h"
#include "vsi_nn_error.h"
#include "vsi_nn_prv.h"
#include "vsi_nn_tensor_util.h"
#include "utils/vsi_nn_util.h"
#include "utils/vsi_nn_dtype_util_prv.h"
#include "kernel/vsi_nn_kernel.h"
#include "libnnext/vx_lib_nnext.h"

__BEGIN_DECLS

typedef enum _LSTMUNIT_nn_activation_type_e
{
    SIGMOID = VSI_NN_ACT_SIGMOID,
    HARD_SIGMOID = VSI_NN_ACT_HARD_SIGMOID,
}LSTMUNIT_nn_activation_type_e;

typedef enum _LSTMUNIT_nn_activation_e
{
    CLP_E = 0x1C,
    LP_E  = 0x14,
    CL_E  = 0x18,
    L_E   = 0x10,
    BP_E  = 0x06,
    B_E   = 0x02,
    CBP_E = 0x0E,
    CB_E  = 0x0A,
    SP_E  = 0x04,
    S_E   = 0x00,
    CSP_E = 0x0C,
    CS_E  = 0x08,
}LSTMUNIT_nn_activation_e;


#define LSTMUNIT_ACTIVATION_HASH_KEY(_is_ln, _is_cifg, _is_proj, _is_hybrid, _is_peephole, \
_input_type, _output_type, _cell_type, _rec_act) \
((_is_ln << 31) | (_is_cifg << 30) | (_is_proj << 29) | (_is_hybrid << 28) | (_is_peephole << 27) \
| (((uint32_t)_input_type) << 23) | (((uint32_t)_output_type) << 19) | (((uint32_t)_cell_type) << 15) \
| (_rec_act << 10))

#define LSTMUNIT_ACTIVATION_SOURCE_NAME(_ln_cifg_proj_hybrid_, _input_type) \
    "lstmunit_activation_"#_ln_cifg_proj_hybrid_"_"#_input_type

#define GEN_LSTMUNIT_STRUCT_ITEMS(_is_ln, _is_cifg, _is_proj, _is_hybrid, _is_peephole, _input_type, _output_type, \
        _cell_type, _rec_act, _ln_cifg_proj_hybrid_) \
    { LSTMUNIT_ACTIVATION_HASH_KEY(_is_ln, _is_cifg, _is_proj, _is_hybrid, _is_peephole, \
    _input_type, _output_type, _cell_type, _rec_act), \
    CVIVANTE_NAMESPACE(\
    "evis.lstmunit_activation_"#_ln_cifg_proj_hybrid_"_"#_input_type"to"#_output_type"_"#_cell_type"_"#_rec_act), \
    LSTMUNIT_ACTIVATION_SOURCE_NAME(_ln_cifg_proj_hybrid_, _input_type) },


typedef struct
{
    uint32_t key;
    char * function_name;
    const char * source_name;
} _kernel_map_type;

static const _kernel_map_type _lstmunit_activation_kernel_map[] =
{
        /* layer norm + cifg + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, F16, F16, F32, SIGMOID, CLP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, F16, F16, F16, SIGMOID, CLP)
        /* layer norm + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 1, 0, 0, F16, F16, F32, SIGMOID, LP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 1, 0, 0, F16, F16, F16, SIGMOID, LP)
        /* layer norm + cifg */
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, F16, F16, F16, SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, F16, I16, F16, SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, F16, U8,  F16, SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, F16, I8,  F16, SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, F16, F16, F32, SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, F16, I16, F32, SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, F16, U8,  F32, SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, F16, I8,  F32, SIGMOID, CL)
        /* layer norm */
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 0, 0, 0, F16, F16, F16, SIGMOID, L)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 0, 0, 0, F16, I16, F16, SIGMOID, L)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 0, 0, 0, F16, U8,  F16, SIGMOID, L)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 0, 0, 0, F16, I8,  F16, SIGMOID, L)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 0, 0, 0, F16, F16, F32, SIGMOID, L)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 0, 0, 0, F16, I16, F32, SIGMOID, L)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 0, 0, 0, F16, U8,  F32, SIGMOID, L)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 0, 0, 0, F16, I8,  F32, SIGMOID, L)
        /* layer norm + cifg + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, F16, I16, F32, SIGMOID, CLP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, F16, I8,  F32, SIGMOID, CLP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, F16, U8,  F32, SIGMOID, CLP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, F16, I16, F16, SIGMOID, CLP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, F16, I8,  F16, SIGMOID, CLP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, F16, U8,  F16, SIGMOID, CLP)
        /* layer norm + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 1, 0, 0, F16, I16, F32, SIGMOID, LP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 1, 0, 0, F16, I8,  F32, SIGMOID, LP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 1, 0, 0, F16, U8,  F32, SIGMOID, LP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 1, 0, 0, F16, I16, F16, SIGMOID, LP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 1, 0, 0, F16, I8,  F16, SIGMOID, LP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 1, 0, 0, F16, U8,  F16, SIGMOID, LP)
        /* hybrid + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, F16, F16, F32, SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, F16, F16, F16, SIGMOID, BP)
        /* hybrid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, F16, F16, F16, SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, F16, I16, F16, SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, F16, U8,  F16, SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, F16, I8,  F16, SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, F16, F16, F32, SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, F16, I16, F32, SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, F16, U8,  F32, SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, F16, I8,  F32, SIGMOID, B)
        /* cifg + hybrid + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, F16, F16, F32, SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, F16, F16, F16, SIGMOID, CBP)
        /* cifg + hybrid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, F16, F16, F16, SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, F16, I16, F16, SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, F16, U8,  F16, SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, F16, I8,  F16, SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, F16, F16, F32, SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, F16, I16, F32, SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, F16, U8,  F32, SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, F16, I8,  F32, SIGMOID, CB)
        /* cifg + hybrid + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, F16, I16, F32, SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, F16, I8,  F32, SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, F16, U8,  F32, SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, F16, I16, F16, SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, F16, I8,  F16, SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, F16, U8,  F16, SIGMOID, CBP)
        /* hybrid + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, F16, I16, F32, SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, F16, I8,  F32, SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, F16, U8,  F32, SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, F16, I16, F16, SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, F16, I8,  F16, SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, F16, U8,  F16, SIGMOID, BP)
        /* hybrid + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, U8,  F16, F32, SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, U8,  F16, F16, SIGMOID, BP)
        /* hybrid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, U8,  F16, F16, SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, U8,  U8,  F16, SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, U8,  F16, F32, SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, U8,  U8,  F32, SIGMOID, B)
        /* cifg + hybrid + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, U8,  F16, F32, SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, U8,  F16, F16, SIGMOID, CBP)
        /* cifg + hybrid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, U8,  F16, F16, SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, U8,  U8,  F16, SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, U8,  F16, F32, SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, U8,  U8,  F32, SIGMOID, CB)
        /* cifg + hybrid + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, U8,  I16, F32, SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, U8,  I8,  F32, SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, U8,  U8,  F32, SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, U8,  I16, F16, SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, U8,  I8,  F16, SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, U8,  U8,  F16, SIGMOID, CBP)
        /* hybrid + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, U8,  I16, F32, SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, U8,  I8,  F32, SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, U8,  U8,  F32, SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, U8,  I16, F16, SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, U8,  I8,  F16, SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, U8,  U8,  F16, SIGMOID, BP)

        /* standard + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, F16, F16, F32, SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, F16, F16, F16, SIGMOID, SP)
        /* standard */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, F16, F16, F16, SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, F16, I16, F16, SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, F16, U8,  F16, SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, F16, I8,  F16, SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, F16, F16, F32, SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, F16, I16, F32, SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, F16, U8,  F32, SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, F16, I8,  F32, SIGMOID, S)
        /* cifg + standard + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, F16, F16, F32, SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, F16, F16, F16, SIGMOID, CSP)
        /* cifg + standard */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, F16, F16, F16, SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, F16, I16, F16, SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, F16, U8,  F16, SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, F16, I8,  F16, SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, F16, F16, F32, SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, F16, I16, F32, SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, F16, U8,  F32, SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, F16, I8,  F32, SIGMOID, CS)
        /* cifg + standard + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, F16, I16, F32, SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, F16, I8,  F32, SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, F16, U8,  F32, SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, F16, I16, F16, SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, F16, I8,  F16, SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, F16, U8,  F16, SIGMOID, CSP)
        /* standard + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, F16, I16, F32, SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, F16, I8,  F32, SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, F16, U8,  F32, SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, F16, I16, F16, SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, F16, I8,  F16, SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, F16, U8,  F16, SIGMOID, SP)
        /* standard + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, U8,  F16, F32, SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, U8,  F16, F16, SIGMOID, SP)
        /* standard */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, U8,  F16, F16, SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, U8,  U8,  F16, SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, U8,  F16, F32, SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, U8,  U8,  F32, SIGMOID, S)
        /* cifg + standard + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, U8,  F16, F32, SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, U8,  F16, F16, SIGMOID, CSP)
        /* cifg + standard */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, U8,  F16, F16, SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, U8,  U8,  F16, SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, U8,  F16, F32, SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, U8,  U8,  F32, SIGMOID, CS)
        /* cifg + standard + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, U8,  I16, F32, SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, U8,  I8,  F32, SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, U8,  U8,  F32, SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, U8,  I16, F16, SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, U8,  I8,  F16, SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, U8,  U8,  F16, SIGMOID, CSP)
        /* standard + projection */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, U8,  I16, F32, SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, U8,  I8,  F32, SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, U8,  U8,  F32, SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, U8,  I16, F16, SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, U8,  I8,  F16, SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, U8,  U8,  F16, SIGMOID, SP)
        /* layer norm + cifg + projection + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, F16, F16, F32, HARD_SIGMOID, CLP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, F16, F16, F16, HARD_SIGMOID, CLP)
        /* layer norm + projection + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 1, 0, 0, F16, F16, F32, HARD_SIGMOID, LP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 1, 0, 0, F16, F16, F16, HARD_SIGMOID, LP)
        /* layer norm + cifg + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, F16, F16, F16, HARD_SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, F16, I16, F16, HARD_SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, F16, U8,  F16, HARD_SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, F16, I8,  F16, HARD_SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, F16, F16, F32, HARD_SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, F16, I16, F32, HARD_SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, F16, U8,  F32, HARD_SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, F16, I8,  F32, HARD_SIGMOID, CL)
        /* layer norm + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 0, 0, 0, F16, F16, F16, HARD_SIGMOID, L)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 0, 0, 0, F16, I16, F16, HARD_SIGMOID, L)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 0, 0, 0, F16, U8,  F16, HARD_SIGMOID, L)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 0, 0, 0, F16, I8,  F16, HARD_SIGMOID, L)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 0, 0, 0, F16, F16, F32, HARD_SIGMOID, L)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 0, 0, 0, F16, I16, F32, HARD_SIGMOID, L)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 0, 0, 0, F16, U8,  F32, HARD_SIGMOID, L)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 0, 0, 0, F16, I8,  F32, HARD_SIGMOID, L)
        /* layer norm + cifg + projection + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, F16, I16, F32, HARD_SIGMOID, CLP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, F16, I8,  F32, HARD_SIGMOID, CLP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, F16, U8,  F32, HARD_SIGMOID, CLP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, F16, I16, F16, HARD_SIGMOID, CLP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, F16, I8,  F16, HARD_SIGMOID, CLP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, F16, U8,  F16, HARD_SIGMOID, CLP)
        /* layer norm + projection + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 1, 0, 0, F16, I16, F32, HARD_SIGMOID, LP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 1, 0, 0, F16, I8,  F32, HARD_SIGMOID, LP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 1, 0, 0, F16, U8,  F32, HARD_SIGMOID, LP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 1, 0, 0, F16, I16, F16, HARD_SIGMOID, LP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 1, 0, 0, F16, I8,  F16, HARD_SIGMOID, LP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 1, 0, 0, F16, U8,  F16, HARD_SIGMOID, LP)
        /* hybrid + projection + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, F16, F16, F32, HARD_SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, F16, F16, F16, HARD_SIGMOID, BP)
        /* hybrid + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, F16, F16, F16, HARD_SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, F16, I16, F16, HARD_SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, F16, U8,  F16, HARD_SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, F16, I8,  F16, HARD_SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, F16, F16, F32, HARD_SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, F16, I16, F32, HARD_SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, F16, U8,  F32, HARD_SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, F16, I8,  F32, HARD_SIGMOID, B)
        /* cifg + hybrid + projection + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, F16, F16, F32, HARD_SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, F16, F16, F16, HARD_SIGMOID, CBP)
        /* cifg + hybrid + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, F16, F16, F16, HARD_SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, F16, I16, F16, HARD_SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, F16, U8,  F16, HARD_SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, F16, I8,  F16, HARD_SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, F16, F16, F32, HARD_SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, F16, I16, F32, HARD_SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, F16, U8,  F32, HARD_SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, F16, I8,  F32, HARD_SIGMOID, CB)
        /* cifg + hybrid + projection + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, F16, I16, F32, HARD_SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, F16, I8,  F32, HARD_SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, F16, U8,  F32, HARD_SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, F16, I16, F16, HARD_SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, F16, I8,  F16, HARD_SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, F16, U8,  F16, HARD_SIGMOID, CBP)
        /* hybrid + projection + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, F16, I16, F32, HARD_SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, F16, I8,  F32, HARD_SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, F16, U8,  F32, HARD_SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, F16, I16, F16, HARD_SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, F16, I8,  F16, HARD_SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, F16, U8,  F16, HARD_SIGMOID, BP)
        /* hybrid + projection + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, U8,  F16, F32, HARD_SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, U8,  F16, F16, HARD_SIGMOID, BP)
        /* hybrid + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, U8,  F16, F16, HARD_SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, U8,  U8,  F16, HARD_SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, U8,  F16, F32, HARD_SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, U8,  U8,  F32, HARD_SIGMOID, B)
        /* cifg + hybrid + projection + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, U8,  F16, F32, HARD_SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, U8,  F16, F16, HARD_SIGMOID, CBP)
        /* cifg + hybrid + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, U8,  F16, F16, HARD_SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, U8,  U8,  F16, HARD_SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, U8,  F16, F32, HARD_SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, U8,  U8,  F32, HARD_SIGMOID, CB)
        /* cifg + hybrid + projection + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, U8,  I16, F32, HARD_SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, U8,  I8,  F32, HARD_SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, U8,  U8,  F32, HARD_SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, U8,  I16, F16, HARD_SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, U8,  I8,  F16, HARD_SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, U8,  U8,  F16, HARD_SIGMOID, CBP)
        /* hybrid + projection + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, U8,  I16, F32, HARD_SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, U8,  I8,  F32, HARD_SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, U8,  U8,  F32, HARD_SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, U8,  I16, F16, HARD_SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, U8,  I8,  F16, HARD_SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, U8,  U8,  F16, HARD_SIGMOID, BP)

        /* standard + projection + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, F16, F16, F32, HARD_SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, F16, F16, F16, HARD_SIGMOID, SP)
        /* standard + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, F16, F16, F16, HARD_SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, F16, I16, F16, HARD_SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, F16, U8,  F16, HARD_SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, F16, I8,  F16, HARD_SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, F16, F16, F32, HARD_SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, F16, I16, F32, HARD_SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, F16, U8,  F32, HARD_SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, F16, I8,  F32, HARD_SIGMOID, S)
        /* cifg + standard + projection + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, F16, F16, F32, HARD_SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, F16, F16, F16, HARD_SIGMOID, CSP)
        /* cifg + standard + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, F16, F16, F16, HARD_SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, F16, I16, F16, HARD_SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, F16, U8,  F16, HARD_SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, F16, I8,  F16, HARD_SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, F16, F16, F32, HARD_SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, F16, I16, F32, HARD_SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, F16, U8,  F32, HARD_SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, F16, I8,  F32, HARD_SIGMOID, CS)
        /* cifg + standard + projection + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, F16, I16, F32, HARD_SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, F16, I8,  F32, HARD_SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, F16, U8,  F32, HARD_SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, F16, I16, F16, HARD_SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, F16, I8,  F16, HARD_SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, F16, U8,  F16, HARD_SIGMOID, CSP)
        /* standard + projection + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, F16, I16, F32, HARD_SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, F16, I8,  F32, HARD_SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, F16, U8,  F32, HARD_SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, F16, I16, F16, HARD_SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, F16, I8,  F16, HARD_SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, F16, U8,  F16, HARD_SIGMOID, SP)
        /* standard + projection + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, U8,  F16, F32, HARD_SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, U8,  F16, F16, HARD_SIGMOID, SP)
        /* standard + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, U8,  F16, F16, HARD_SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, U8,  U8,  F16, HARD_SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, U8,  F16, F32, HARD_SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, U8,  U8,  F32, HARD_SIGMOID, S)
        /* cifg + standard + projection + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, U8,  F16, F32, HARD_SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, U8,  F16, F16, HARD_SIGMOID, CSP)
        /* cifg + standard + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, U8,  F16, F16, HARD_SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, U8,  U8,  F16, HARD_SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, U8,  F16, F32, HARD_SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, U8,  U8,  F32, HARD_SIGMOID, CS)
        /* cifg + standard + projection + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, U8,  I16, F32, HARD_SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, U8,  I8,  F32, HARD_SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, U8,  U8,  F32, HARD_SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, U8,  I16, F16, HARD_SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, U8,  I8,  F16, HARD_SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, U8,  U8,  F16, HARD_SIGMOID, CSP)
        /* standard + projection + hard_sigmoid */
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, U8,  I16, F32, HARD_SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, U8,  I8,  F32, HARD_SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, U8,  U8,  F32, HARD_SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, U8,  I16, F16, HARD_SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, U8,  I8,  F16, HARD_SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, U8,  U8,  F16, HARD_SIGMOID, SP)

        /* BF16 type */
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, BF16, BF16, BF16, SIGMOID, CLP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 1, 0, 0, BF16, BF16, BF16, SIGMOID, LP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, BF16, BF16, BF16, SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 0, 0, 0, BF16, BF16, BF16, SIGMOID, L)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, BF16, BF16, BF16, SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, BF16, BF16, BF16, SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, BF16, BF16, BF16, SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, BF16, BF16, BF16, SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, BF16, BF16, BF16, SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, BF16, BF16, BF16, SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, BF16, BF16, BF16, SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, BF16, BF16, BF16, SIGMOID, CS)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 1, 0, 0, BF16, BF16, BF16, HARD_SIGMOID, CLP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 1, 0, 0, BF16, BF16, BF16, HARD_SIGMOID, LP)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 1, 0, 0, 0, BF16, BF16, BF16, HARD_SIGMOID, CL)
        GEN_LSTMUNIT_STRUCT_ITEMS(1, 0, 0, 0, 0, BF16, BF16, BF16, HARD_SIGMOID, L)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 1, 0, BF16, BF16, BF16, HARD_SIGMOID, BP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 1, 0, BF16, BF16, BF16, HARD_SIGMOID, B)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 1, 0, BF16, BF16, BF16, HARD_SIGMOID, CBP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 1, 0, BF16, BF16, BF16, HARD_SIGMOID, CB)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 1, 0, 0, BF16, BF16, BF16, HARD_SIGMOID, SP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 0, 0, 0, 0, BF16, BF16, BF16, HARD_SIGMOID, S)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 1, 0, 0, BF16, BF16, BF16, HARD_SIGMOID, CSP)
        GEN_LSTMUNIT_STRUCT_ITEMS(0, 1, 0, 0, 0, BF16, BF16, BF16, HARD_SIGMOID, CS)
};


typedef enum _lstmunit_cifg_ln_proj_e
{
    CLP_INPUT_FC_F,
    CLP_INPUT_FC_C,
    CLP_INPUT_FC_O,
    CLP_CSTATE_IN,
    CLP_BIASES_F,
    CLP_BIASES_C,
    CLP_BIASES_O,
    CLP_LN_WF,
    CLP_LN_WC,
    CLP_LN_WO,
    CLP_OUTPUT,
    CLP_CSTATE_OUT,
    CLP_PARAM
} lstmunit_cifg_ln_proj_e;

static vx_param_description_t vxLSTMUNIT_CLP_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_CLP_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_CLP_Param )

typedef enum _lstmunit_cifg_ln_e
{
    CL_INPUT_FC_F,
    CL_INPUT_FC_C,
    CL_INPUT_FC_O,
    CL_CSTATE_IN,
    CL_BIASES_F,
    CL_BIASES_C,
    CL_BIASES_O,
    CL_LN_WF,
    CL_LN_WC,
    CL_LN_WO,
    CL_OUTPUT,
    CL_CSTATE_OUT,
    CL_HSTATE_OUT,
    CL_LSTMUNIT_PARAM,
} lstmunit_cifg_ln_e;

static vx_param_description_t vxLSTMUNIT_CL_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_CL_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_CL_Param )

typedef enum _lstmunit_ln_proj_e
{
    LP_INPUT_FC_I,
    LP_INPUT_FC_F,
    LP_INPUT_FC_C,
    LP_INPUT_FC_O,
    LP_CSTATE_IN,
    LP_BIASES_I,
    LP_BIASES_F,
    LP_BIASES_C,
    LP_BIASES_O,
    LP_LN_WI,
    LP_LN_WF,
    LP_LN_WC,
    LP_LN_WO,
    LP_OUTPUT,
    LP_CSTATE_OUT,
    LP_PARAM
} lstmunit_ln_proj_e;

static vx_param_description_t vxLSTMUNIT_LP_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_LP_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_LP_Param )

typedef enum _lstmunit_ln_e
{
    L_INPUT_FC_I,
    L_INPUT_FC_F,
    L_INPUT_FC_C,
    L_INPUT_FC_O,
    L_CSTATE_IN,
    L_BIASES_I,
    L_BIASES_F,
    L_BIASES_C,
    L_BIASES_O,
    L_LN_WI,
    L_LN_WF,
    L_LN_WC,
    L_LN_WO,
    L_OUTPUT,
    L_CSTATE_OUT,
    L_HSTATE_OUT,
    L_LSTMUNIT_PARAM,
} lstmunit_ln_e;

static vx_param_description_t vxLSTMUNIT_L_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_L_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_L_Param )

typedef enum _lstmunit_hybrid_proj_e
{
    BP_INPUT_FC_I,
    BP_INPUT_FC_F,
    BP_INPUT_FC_C,
    BP_INPUT_FC_O,
    BP_CSTATE_IN,
    BP_HSTATE_FC_I,
    BP_HSTATE_FC_F,
    BP_HSTATE_FC_C,
    BP_HSTATE_FC_O,
    BP_BIASES_I,
    BP_BIASES_F,
    BP_BIASES_C,
    BP_BIASES_O,
    BP_OUTPUT,
    BP_CSTATE_OUT,
    BP_PARAM
} lstmunit_hybrid_proj_e;

static vx_param_description_t vxLSTMUNIT_BP_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_BP_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_BP_Param )

typedef enum _lstmunit_hybrid_e
{
    B_INPUT_FC_I,
    B_INPUT_FC_F,
    B_INPUT_FC_C,
    B_INPUT_FC_O,
    B_CSTATE_IN,
    B_HSTATE_FC_I,
    B_HSTATE_FC_F,
    B_HSTATE_FC_C,
    B_HSTATE_FC_O,
    B_BIASES_I,
    B_BIASES_F,
    B_BIASES_C,
    B_BIASES_O,
    B_OUTPUT,
    B_CSTATE_OUT,
    B_HSTATE_OUT,
    B_LSTMUNIT_PARAM,
} lstmunit_hybrid_e;

static vx_param_description_t vxLSTMUNIT_B_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_B_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_B_Param )

typedef enum _lstmunit_cifg_hybrid_proj_e
{
    CBP_INPUT_FC_F,
    CBP_INPUT_FC_C,
    CBP_INPUT_FC_O,
    CBP_CSTATE_IN,
    CBP_HSTATE_FC_F,
    CBP_HSTATE_FC_C,
    CBP_HSTATE_FC_O,
    CBP_BIASES_F,
    CBP_BIASES_C,
    CBP_BIASES_O,
    CBP_OUTPUT,
    CBP_CSTATE_OUT,
    CBP_PARAM
} lstmunit_cifg_hybrid_proj_e;

static vx_param_description_t vxLSTMUNIT_CBP_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_CBP_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_CBP_Param )

typedef enum _lstmunit_cifg_hybrid_e
{
    CB_INPUT_FC_F,
    CB_INPUT_FC_C,
    CB_INPUT_FC_O,
    CB_CSTATE_IN,
    CB_HSTATE_FC_F,
    CB_HSTATE_FC_C,
    CB_HSTATE_FC_O,
    CB_BIASES_F,
    CB_BIASES_C,
    CB_BIASES_O,
    CB_OUTPUT,
    CB_CSTATE_OUT,
    CB_HSTATE_OUT,
    CB_LSTMUNIT_PARAM,
} lstmunit_cifg_hybrid_e;

static vx_param_description_t vxLSTMUNIT_CB_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_CB_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_CB_Param )

typedef enum _lstmunit_standard_proj_e
{
    SP_INPUT_FC_I,
    SP_INPUT_FC_F,
    SP_INPUT_FC_C,
    SP_INPUT_FC_O,
    SP_CSTATE_IN,
    SP_HSTATE_FC_I,
    SP_HSTATE_FC_F,
    SP_HSTATE_FC_C,
    SP_HSTATE_FC_O,
    SP_OUTPUT,
    SP_CSTATE_OUT,
    SP_PARAM
} lstmunit_standard_proj_e;

static vx_param_description_t vxLSTMUNIT_SP_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_SP_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_SP_Param )

typedef enum _lstmunit_standard_e
{
    S_INPUT_FC_I,
    S_INPUT_FC_F,
    S_INPUT_FC_C,
    S_INPUT_FC_O,
    S_CSTATE_IN,
    S_HSTATE_FC_I,
    S_HSTATE_FC_F,
    S_HSTATE_FC_C,
    S_HSTATE_FC_O,
    S_OUTPUT,
    S_CSTATE_OUT,
    S_HSTATE_OUT,
    S_LSTMUNIT_PARAM,
} lstmunit_standard_e;

static vx_param_description_t vxLSTMUNIT_S_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_S_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_S_Param )

typedef enum _lstmunit_cifg_standard_proj_e
{
    CSP_INPUT_FC_F,
    CSP_INPUT_FC_C,
    CSP_INPUT_FC_O,
    CSP_CSTATE_IN,
    CSP_HSTATE_FC_F,
    CSP_HSTATE_FC_C,
    CSP_HSTATE_FC_O,
    CSP_OUTPUT,
    CSP_CSTATE_OUT,
    CSP_PARAM
} lstmunit_cifg_standard_proj_e;

static vx_param_description_t vxLSTMUNIT_CSP_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_CSP_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_CSP_Param )

typedef enum _lstmunit_cifg_standard_e
{
    CS_INPUT_FC_F,
    CS_INPUT_FC_C,
    CS_INPUT_FC_O,
    CS_CSTATE_IN,
    CS_HSTATE_FC_F,
    CS_HSTATE_FC_C,
    CS_HSTATE_FC_O,
    CS_OUTPUT,
    CS_CSTATE_OUT,
    CS_HSTATE_OUT,
    CS_LSTMUNIT_PARAM,
} lstmunit_cifg_standard_e;

static vx_param_description_t vxLSTMUNIT_CS_Param[] =
{
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_OUTPUT, VX_TYPE_TENSOR, VX_PARAMETER_STATE_REQUIRED},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
    {VX_INPUT,  VX_TYPE_SCALAR, VX_PARAMETER_STATE_OPTIONAL},
};

#define _LSTMUNIT_ACTIVATION_CS_PARAM_NUM  _cnt_of_array( vxLSTMUNIT_CS_Param )

#define _LSTMUINT_PARAM_NUM 5

#define _LSTMUNIT_ACTIVATION_MAX_PARAM_NUM (LSTMUNIT_ACT_PARAM_COUT + _LSTMUINT_PARAM_NUM)

/*
 * Kernel initializer
 */
DEF_KERNEL_INITIALIZER(_lstmunit_activation_initializer)
    (
    vsi_nn_kernel_node_t                node,
    const vsi_nn_kernel_node_param_t  * param,
    size_t                              param_size
    )
{
    gpu_param_t gpu_param = {
        2,
        {0, 0, 0},
        {0, 0, 0},
        {0, 0, 0},
        {0, 0, 0}
        };
    vsi_status                   status                 = VSI_FAILURE;
    vsi_nn_kernel_tensor_t       cell_state_in          = NULL;
    vsi_nn_kernel_tensor_t       output                 = NULL;
    float                        cell_clip              = 0.0f;
    float                        forget_bias            = 0.0f;
    float                        outputScale            = 1.0f;
    float                        outputZP               = 0;
    vsi_nn_kernel_dtype_e        cellFormat             = F16;
    vsi_nn_kernel_dtype_e        dstFormat              = F16;
    float                        logE                   = (float)(log10(exp(1.0f)) / log10(2.0f));
    float                        twoLogE                = 2 * logE;
    uint32_t                     uint_min               = 0xFBFFFFFF;
    uint32_t                     uint_max               = 0x7BFFFFFF;
    float                        float_min              = 0.0f;
    float                        float_max              = 0.0f;
    float                        clip_Min_F[4]          = {0};
    float                        clip_Max_F[4]          = {0};
    uint32_t                     i                      = 0;
    int32_t                      input0Array_ZP[4]      = {0};
    int32_t                      input1Array_ZP[4]      = {0};
    float                        input0Array_Scale[4]   = {1.0f};
    float                        input1Array_Scale[4]   = {1.0f};
    int32_t                      _is_ln                 = 0;
    int32_t                      _is_cifg               = 0;
    int32_t                      _is_hybrid             = 0;
    vsi_nn_kernel_tensor_attr_t* input_attr[9]          = {NULL};
    vsi_nn_kernel_tensor_attr_t* attr[2]                = {NULL};

    fp32_bit_cast_t fp32_bit_cast;
    fp32_bit_cast.data = uint_min;
    float_min = fp32_bit_cast.val;
    fp32_bit_cast.data = uint_max;
    float_max = fp32_bit_cast.val;

    status = vsi_nn_kernel_scalar_read_int32( (vsi_nn_kernel_scalar_t)param[param_size - 5], &_is_ln );
    CHECK_STATUS_FAIL_GOTO(status, final );
    status = vsi_nn_kernel_scalar_read_int32( (vsi_nn_kernel_scalar_t)param[param_size - 4], &_is_cifg );
    CHECK_STATUS_FAIL_GOTO(status, final );
    status = vsi_nn_kernel_scalar_read_int32( (vsi_nn_kernel_scalar_t)param[param_size - 3], &_is_hybrid );
    CHECK_STATUS_FAIL_GOTO(status, final );
    if (_is_cifg)
    {
        cell_state_in = (vsi_nn_kernel_tensor_t)param[CL_CSTATE_IN];
        if (_is_ln)
            output = (vsi_nn_kernel_tensor_t)param[CL_OUTPUT];
        else if (_is_hybrid)
            output = (vsi_nn_kernel_tensor_t)param[CB_OUTPUT];
        else
            output = (vsi_nn_kernel_tensor_t)param[CS_OUTPUT];
    }
    else
    {
        cell_state_in = (vsi_nn_kernel_tensor_t)param[L_CSTATE_IN];
        if (_is_ln)
            output = (vsi_nn_kernel_tensor_t)param[L_OUTPUT];
        else if (_is_hybrid)
            output = (vsi_nn_kernel_tensor_t)param[B_OUTPUT];
        else
            output = (vsi_nn_kernel_tensor_t)param[S_OUTPUT];
    }

    for (i = 0; i < 9; i++)
    {
        input_attr[i] = vsi_nn_kernel_tensor_attr_create( (vsi_nn_kernel_tensor_t)param[i] );
        CHECK_PTR_FAIL_GOTO( input_attr[i], "Create tensor attr buffer fail.", final );
    }
    attr[0] = vsi_nn_kernel_tensor_attr_create( cell_state_in );
    CHECK_PTR_FAIL_GOTO( attr[0], "Create tensor attr buffer fail.", final );
    attr[1] = vsi_nn_kernel_tensor_attr_create( output );
    CHECK_PTR_FAIL_GOTO( attr[1], "Create tensor attr buffer fail.", final );

    status = vsi_nn_kernel_scalar_read_float32( (vsi_nn_kernel_scalar_t)param[param_size - 2], &cell_clip );
    CHECK_STATUS_FAIL_GOTO(status, final );
    status = vsi_nn_kernel_scalar_read_float32( (vsi_nn_kernel_scalar_t)param[param_size - 1], &forget_bias );
    CHECK_STATUS_FAIL_GOTO(status, final );

    cellFormat   = attr[0]->dtype;
    dstFormat    = attr[1]->dtype;

    outputScale  = 1.0f / attr[1]->scale;
    outputZP     = (float)attr[1]->zero_point;

    gpu_param.global_scale[0]  = 4;
    gpu_param.global_scale[1]  = 1;
    gpu_param.global_size[0]   = gpu_align_p2((attr[1]->shape->data[0] + gpu_param.global_scale[0] - 1)
        / gpu_param.global_scale[0], 4);
    gpu_param.global_size[1]   = (attr[1]->shape->data[1] + gpu_param.global_scale[1] - 1)
        / gpu_param.global_scale[1];


    if (cell_clip > 0)
    {
        float_max = cell_clip;
        float_min = -cell_clip;
    }

    for (i = 0; i < 4; i++)
    {
        clip_Min_F[i] = float_min;
        clip_Max_F[i] = float_max;
    }

    {
        gpu_dp_inst_t uniFp16toFp32_4x4 = {{
            0x01010101, // TCfg
            0x00000000, // ASelt
            0x00010000, 0x00030002, // ABin
            0x02020202, // BSelt
            0x00000000, 0x00000000, // BBin
            0x00000100, // AccumType, ConstantType, and PostShift
            0x00003c00, 0x00000000, 0x00003c00, 0x00000000,
            0x00003c00, 0x00000000, 0x00003c00, 0x00000000 // Constant
        }, GPU_DP_TYPE_16};
        gpu_dp_inst_t uniExtractHalf4_4x4 = {{
            0x01010101, // TCfg
            0x00000000, // ASelt
            0x00020000, 0x00060004, // ABin
            0x02020202, // BSelt
            0x00000000, 0x00000000, // BBin
            0x00000100, // AccumType, ConstantType, and PostShift
            0x00003c00, 0x00000000, 0x00003c00, 0x00000000,
            0x00003c00, 0x00000000, 0x00003c00, 0x00000000 // Constant
        }, GPU_DP_TYPE_16};
        gpu_dp_inst_t uniExtractInteger_2x8 = {{
            0x33333333, // TCfg
            0x11110000, // ASelt
            0x03020100, 0x03020100, // ABin
            0x00000000, // BSelt
            0x00000000, 0x00000000, // BBin
            0x00002400, // AccumType, ConstantType, and PostShift
            0x00000000, 0x00000000, 0x00000000, 0x00000000,
            0x00000000, 0x00000000, 0x00000000, 0x00000000 // Constant
        }, GPU_DP_TYPE_16};
        gpu_dp_inst_t uniExtractHalf8_2x8 = {{
            0x11111111, // TCfg
            0x11110000, // ASelt
            0x06040200, 0x06040200, // ABin
            0x22222222, // BSelt
            0x00000000, 0x00000000, // BBin
            0x00000100, // AccumType, ConstantType, and PostShift
            0x00003c00, 0x00003c00, 0x00003c00, 0x00003c00,
            0x00003c00, 0x00003c00, 0x00003c00, 0x00003c00 // Constant
        }, GPU_DP_TYPE_16};
        gpu_dp_inst_t uniFp16AddFp16toFp32_4x4 = {{
            0x05050505, // TCfg
            0x04040404, // ASelt
            0x00110000, 0x00330022, // ABin
            0x0a0a0a0a, // BSelt
            0x00000000, 0x00000000, // BBin
            0x00000100, // AccumType, ConstantType, and PostShift
            0x3c003c00, 0x00000000, 0x3c003c00, 0x00000000,
            0x3c003c00, 0x00000000, 0x3c003c00, 0x00000000 // Constant
        }, GPU_DP_TYPE_16};
        gpu_dp_inst_t uniU8AddS32_4x4 = {{
            0x0d0d0d0d, // TCfg
            0x04040404, // ASelt
            0x00010000, 0x00030002, // ABin
            0x02020202, // BSelt
            0x00000000, 0x00000000, // BBin
            0x00002600, // AccumType, ConstantType, and PostShift
            0x00000001, 0x00000000, 0x00000001, 0x00000000,
            0x00000001, 0x00000000, 0x00000001, 0x00000000 // Constant
        }, GPU_DP_TYPE_16};
        gpu_dp_inst_t uniConvBF16toF32_Part0_2x8 = {{
            0x11111111, // TCfg
            0x01010101, // ASelt
            0x01050004, 0x03070206, // ABin
            0x22222222, // BSelt
            0x00000000, 0x00000000, // BBin
            0x00000600, // AccumType, ConstantType, and PostShift
            0x00000001, 0x00000001, 0x00000001, 0x00000001,
            0x00000001, 0x00000001, 0x00000001, 0x00000001 // Constant
        }, GPU_DP_TYPE_16};
        gpu_dp_inst_t uniExtractOddData_2x8 = {{
            0x11111111, // TCfg
            0x11110000, // ASelt
            0x07050301, 0x07050301, // ABin
            0x22222222, // BSelt
            0x00000000, 0x00000000, // BBin
            0x00000600, // AccumType, ConstantType, and PostShift
            0x00000001, 0x00000001, 0x00000001, 0x00000001,
            0x00000001, 0x00000001, 0x00000001, 0x00000001 // Constant
        }, GPU_DP_TYPE_16};

        if ( cellFormat == F16 )
        {
            status |= vsi_nn_kernel_gpu_add_param(node, "uniExtractHalf4_4x4", &uniExtractHalf4_4x4);
        }

        if ( dstFormat == F16 )
        {
            status |= vsi_nn_kernel_gpu_add_param(node, "uniExtract8Data_2x8", &uniExtractHalf8_2x8);
        }
        else if ( dstFormat != BF16 )
        {
            status |= vsi_nn_kernel_gpu_add_param(node, "uniExtract8Data_2x8", &uniExtractInteger_2x8);
        }

        if ( cellFormat == BF16 && dstFormat == BF16)
        {
            status |= vsi_nn_kernel_gpu_add_param(node, "uniConvBF16toF32_Part0_2x8", &uniConvBF16toF32_Part0_2x8);
            status |= vsi_nn_kernel_gpu_add_param(node, "uniExtractOddData_2x8", &uniExtractOddData_2x8);
        }
        else
        {
            status |= vsi_nn_kernel_gpu_add_param(node, "uniFp16toFp32_4x4", &uniFp16toFp32_4x4);
        }
        CHECK_STATUS_FAIL_GOTO(status, final );

        status = vsi_nn_kernel_gpu_add_param(node, "logE", &logE);
        status |= vsi_nn_kernel_gpu_add_param(node, "twoLogE", &twoLogE);
        status |= vsi_nn_kernel_gpu_add_param(node, "outputScale", &outputScale);
        status |= vsi_nn_kernel_gpu_add_param(node, "outputZP", &outputZP);
        status |= vsi_nn_kernel_gpu_add_param(node, "forget_bias", &forget_bias);
        status |= vsi_nn_kernel_gpu_add_param(node, "clip_Min_F", clip_Min_F);
        status |= vsi_nn_kernel_gpu_add_param(node, "clip_Max_F", clip_Max_F);
        if ( !_is_ln && input_attr[S_INPUT_FC_F]->dtype == F16 )
        {
            status |= vsi_nn_kernel_gpu_add_param(node, "uniFp16AddFp16toFp32_4x4", &uniFp16AddFp16toFp32_4x4);
        }
        CHECK_STATUS_FAIL_GOTO(status, final );

        if (input_attr[S_INPUT_FC_F]->dtype == U8 &&
            input_attr[S_INPUT_FC_F]->quant == VSI_NN_KERNEL_QUANT_ASYMM)
        {
            if (_is_cifg)
            {
                input0Array_ZP[1]    = 0 -  input_attr[CS_INPUT_FC_F]->asymm.zero_point;
                input0Array_ZP[2]    = 0 -  input_attr[CS_INPUT_FC_C]->asymm.zero_point;
                input0Array_ZP[3]    = 0 -  input_attr[CS_INPUT_FC_O]->asymm.zero_point;

                input0Array_Scale[1] = input_attr[CS_INPUT_FC_F]->asymm.scale;
                input0Array_Scale[2] = input_attr[CS_INPUT_FC_C]->asymm.scale;
                input0Array_Scale[3] = input_attr[CS_INPUT_FC_O]->asymm.scale;

                if ( !_is_ln )
                {
                    input1Array_ZP[1]    = 0 -  input_attr[CS_HSTATE_FC_F]->asymm.zero_point;
                    input1Array_ZP[2]    = 0 -  input_attr[CS_HSTATE_FC_C]->asymm.zero_point;
                    input1Array_ZP[3]    = 0 -  input_attr[CS_HSTATE_FC_O]->asymm.zero_point;

                    input1Array_Scale[1] = input_attr[CS_HSTATE_FC_F]->asymm.scale;
                    input1Array_Scale[2] = input_attr[CS_HSTATE_FC_C]->asymm.scale;
                    input1Array_Scale[3] = input_attr[CS_HSTATE_FC_O]->asymm.scale;
                }
            }
            else
            {
                input0Array_ZP[0]    = 0 -  input_attr[S_INPUT_FC_I]->asymm.zero_point;
                input0Array_ZP[1]    = 0 -  input_attr[S_INPUT_FC_F]->asymm.zero_point;
                input0Array_ZP[2]    = 0 -  input_attr[S_INPUT_FC_C]->asymm.zero_point;
                input0Array_ZP[3]    = 0 -  input_attr[S_INPUT_FC_O]->asymm.zero_point;

                input0Array_Scale[0] = input_attr[S_INPUT_FC_I]->asymm.scale;
                input0Array_Scale[1] = input_attr[S_INPUT_FC_F]->asymm.scale;
                input0Array_Scale[2] = input_attr[S_INPUT_FC_C]->asymm.scale;
                input0Array_Scale[3] = input_attr[S_INPUT_FC_O]->asymm.scale;

                if ( !_is_ln )
                {
                    input1Array_ZP[0]    = 0 -  input_attr[S_HSTATE_FC_I]->asymm.zero_point;
                    input1Array_ZP[1]    = 0 -  input_attr[S_HSTATE_FC_F]->asymm.zero_point;
                    input1Array_ZP[2]    = 0 -  input_attr[S_HSTATE_FC_C]->asymm.zero_point;
                    input1Array_ZP[3]    = 0 -  input_attr[S_HSTATE_FC_O]->asymm.zero_point;

                    input1Array_Scale[0] = input_attr[S_HSTATE_FC_I]->asymm.scale;
                    input1Array_Scale[1] = input_attr[S_HSTATE_FC_F]->asymm.scale;
                    input1Array_Scale[2] = input_attr[S_HSTATE_FC_C]->asymm.scale;
                    input1Array_Scale[3] = input_attr[S_HSTATE_FC_O]->asymm.scale;
                }
            }

            vsi_nn_kernel_gpu_add_param(node, "input0Array_ZP", input0Array_ZP);
            vsi_nn_kernel_gpu_add_param(node, "input0Array_Scale", input0Array_Scale);
            vsi_nn_kernel_gpu_add_param(node, "input1Array_ZP", input1Array_ZP);
            vsi_nn_kernel_gpu_add_param(node, "input1Array_Scale", input1Array_Scale);
            vsi_nn_kernel_gpu_add_param(node, "uniU8AddS32_4x4", &uniU8AddS32_4x4);
        }
    }

    status = vsi_nn_kernel_gpu_config( node, &gpu_param );
    CHECK_STATUS_FAIL_GOTO(status, final );
final:
    for (i = 0; i < 9; i++)
    {
        if (input_attr[i])
        {
            vsi_nn_kernel_tensor_attr_release( &input_attr[i] );
        }
    }
    if (attr[0])
    {
        vsi_nn_kernel_tensor_attr_release( &attr[0] );
    }

    if (attr[1])
    {
        vsi_nn_kernel_tensor_attr_release( &attr[1] );
    }

    return status;

} /* _lstmunit_activation_initializer() */


static size_t get_param_num(LSTMUNIT_nn_activation_e lstm_activation)
{
    size_t   lstm_activation_param_num = LSTMUNIT_ACT_PARAM_COUT;

    switch (lstm_activation)
    {
        case CLP_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_CLP_PARAM_NUM;
        break;
        case LP_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_LP_PARAM_NUM;
        break;
        case CL_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_CL_PARAM_NUM;
        break;
        case L_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_L_PARAM_NUM;
        break;
        case BP_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_BP_PARAM_NUM;
        break;
        case B_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_B_PARAM_NUM;
        break;
        case CBP_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_CBP_PARAM_NUM;
        break;
        case CB_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_CB_PARAM_NUM;
        break;
        case SP_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_SP_PARAM_NUM;
        break;
        case S_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_S_PARAM_NUM;
        break;
        case CSP_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_CSP_PARAM_NUM;
        break;
        case CS_E:
            lstm_activation_param_num = _LSTMUNIT_ACTIVATION_CS_PARAM_NUM;
        break;
        default:
        break;
    }
    return lstm_activation_param_num;
}

static void set_vx_param_description_t(LSTMUNIT_nn_activation_e lstm_activation, vx_param_description_t ** param_def)
{
    switch (lstm_activation)
    {
        case CLP_E:
            *param_def = vxLSTMUNIT_CLP_Param;
        break;
        case LP_E:
            *param_def = vxLSTMUNIT_LP_Param;
        break;
        case CL_E:
            *param_def = vxLSTMUNIT_CL_Param;
        break;
        case L_E:
            *param_def = vxLSTMUNIT_L_Param;
        break;
        case BP_E:
            *param_def = vxLSTMUNIT_BP_Param;
        break;
        case B_E:
            *param_def = vxLSTMUNIT_B_Param;
        break;
        case CBP_E:
            *param_def = vxLSTMUNIT_CBP_Param;
        break;
        case CB_E:
            *param_def = vxLSTMUNIT_CB_Param;
        break;
        case SP_E:
            *param_def = vxLSTMUNIT_SP_Param;
        break;
        case S_E:
            *param_def = vxLSTMUNIT_S_Param;
        break;
        case CSP_E:
            *param_def = vxLSTMUNIT_CSP_Param;
        break;
        case CS_E:
            *param_def = vxLSTMUNIT_CS_Param;
        break;
        default:
        break;
    }
}

/*
 * Query kernel
 */
static vsi_status _query_kernel
    (
    vsi_nn_kernel_t * kernel,
    vsi_nn_tensor_t * const * const inputs,
    vsi_nn_tensor_t * const * const outputs,
    int32_t  _is_ln,
    int32_t  _is_cifg,
    int32_t  _is_proj,
    int32_t  _is_hybrid,
    int32_t  _is_peephole,
    int32_t  recurrent_activation,
    LSTMUNIT_nn_activation_e lstm_activation
    )
{
    vsi_status status = VSI_FAILURE;
    vsi_nn_kernel_dtype_e in_dtype;
    vsi_nn_kernel_dtype_e cell_dtype;
    vsi_nn_kernel_dtype_e out_dtype;
    const _kernel_map_type * kernel_map = _lstmunit_activation_kernel_map;
    size_t kernel_map_size              = _cnt_of_array( _lstmunit_activation_kernel_map );
    vx_param_description_t * param_def  = NULL;
    size_t param_def_size               = _LSTMUNIT_ACTIVATION_MAX_PARAM_NUM;
    vx_kernel_initialize_f  initializer = _lstmunit_activation_initializer;
    uint32_t key = 0;
    uint32_t i = 0;

    set_vx_param_description_t( lstm_activation, &param_def );

    if (NULL == param_def)
    {
        status = VSI_FAILURE;
        return status;
    }

    param_def_size = get_param_num(lstm_activation);
    in_dtype   = vsi_nn_kernel_map_dtype( inputs[LSTMUNIT_ACT_INPUT_FC_F]->attr.dtype.vx_type );
    cell_dtype = vsi_nn_kernel_map_dtype( inputs[LSTMUNIT_ACT_CSTATE_IN]->attr.dtype.vx_type );
    out_dtype  = vsi_nn_kernel_map_dtype( outputs[0]->attr.dtype.vx_type );
    key = LSTMUNIT_ACTIVATION_HASH_KEY(_is_ln, _is_cifg, _is_proj, _is_hybrid, _is_peephole, \
    in_dtype, out_dtype, cell_dtype, recurrent_activation);

    for( i = 0; i < kernel_map_size; i ++ )
    {
        if( kernel_map[i].key == key )
        {
            break;
        }
    }

    if( i < kernel_map_size )
    {
        snprintf( kernel->info.name, VX_MAX_KERNEL_NAME, "%s",  kernel_map[i].function_name );
        kernel->info.parameters  = param_def;
        kernel->info.numParams   = (uint32_t)param_def_size;
        kernel->info.initialize  = initializer;
        // Register code source
        vsi_nn_kernel_add_source( kernel, VSI_NN_GPU_SOURCE_FMT_CODE, 2,
                "vsi_nn_kernel_header",
                kernel_map[i].source_name );
        // Register binary source
        vsi_nn_kernel_add_source( kernel, VSI_NN_GPU_SOURCE_FMT_EXECUTABLE, 1,
                kernel_map[i].source_name );
        status = VSI_SUCCESS;
    }

    return status;

} /* _query_kernel() */


static vsi_nn_kernel_node_t _setup
    (
    vsi_nn_graph_t              * graph,
    vsi_nn_tensor_t            ** inputs,
    size_t                        input_num,
    vsi_nn_tensor_t            ** outputs,
    size_t                        output_num,
    const vsi_nn_kernel_param_t * params,
    vsi_nn_kernel_t             * kernel
    )
{
    vsi_status status = VSI_FAILURE;
    vsi_nn_kernel_node_param_t node_params[_LSTMUNIT_ACTIVATION_MAX_PARAM_NUM] = {NULL};
    vsi_nn_kernel_node_t node = NULL;
    vsi_nn_tensor_t* in_tensor[LSTMUNIT_ACT_INPUTS_COUNT] = {NULL};
    vsi_nn_tensor_t* out_tensor[LSTMUNIT_ACT_OUTUTS_COUNT] = {NULL};
    size_t   input_cnt  = 0;
    size_t   output_cnt = 0;
    int32_t  _is_ln= 0;
    int32_t  _is_cifg= 0;
    int32_t  _is_proj= 0;
    int32_t  _is_hybrid= 0;
    int32_t  _is_peephole= 0;
    int32_t  recurrent_activation;
    float    cell_clip;
    float    forget_bias;
    LSTMUNIT_nn_activation_e lstm_activation;
    size_t   lstm_activation_param_num = _LSTMUNIT_ACTIVATION_MAX_PARAM_NUM;

    _is_ln               = vsi_nn_kernel_param_get_int32( params, "_is_ln" );
    _is_cifg             = vsi_nn_kernel_param_get_int32( params, "_is_cifg" );
    _is_proj             = vsi_nn_kernel_param_get_int32( params, "_is_proj" );
    _is_hybrid           = vsi_nn_kernel_param_get_int32( params, "_is_hybrid" );
    _is_peephole         = vsi_nn_kernel_param_get_int32( params, "_is_peephole" );
    recurrent_activation = vsi_nn_kernel_param_get_int32( params, "recurrent_activation" );
    cell_clip            = vsi_nn_kernel_param_get_float32(params, "cell_clip");
    forget_bias          = vsi_nn_kernel_param_get_float32(params, "forget_bias");

    lstm_activation      = (LSTMUNIT_nn_activation_e)((_is_ln << 4) | \
    (_is_cifg << 3) | (_is_proj << 2) | (_is_hybrid << 1) | (_is_peephole));
    status = _query_kernel( kernel, inputs, outputs, \
    _is_ln, _is_cifg, _is_proj, _is_hybrid, _is_peephole, recurrent_activation, lstm_activation);

    if( VSI_SUCCESS == status)
    {
        node = vsi_nn_kernel_create_node( graph, kernel );
        if( node )
        {
            uint32_t i;

            for (i = 0; i < input_num; i++)
            {
                if (inputs[i])
                {
                    in_tensor[input_cnt] = inputs[i];
                    input_cnt++;
                }
            }
            for (i = 0; i < output_num; i++)
            {
                if (outputs[i])
                {
                    out_tensor[output_cnt] = outputs[i];
                    output_cnt++;
                }
            }
            lstm_activation_param_num = get_param_num(lstm_activation);
            /* Set inputs and outputs */
            vsi_nn_kernel_node_pack_io( node_params, lstm_activation_param_num,
                    in_tensor, input_cnt, out_tensor, output_cnt );
            node_params[lstm_activation_param_num - _LSTMUINT_PARAM_NUM] = vsi_nn_kernel_scalar_create(
                    graph, I32, &_is_ln );
            node_params[lstm_activation_param_num - _LSTMUINT_PARAM_NUM + 1] = vsi_nn_kernel_scalar_create(
                    graph, I32, &_is_cifg );
            node_params[lstm_activation_param_num - _LSTMUINT_PARAM_NUM + 2] = vsi_nn_kernel_scalar_create(
                    graph, I32, &_is_hybrid );
            node_params[lstm_activation_param_num - _LSTMUINT_PARAM_NUM + 3] = vsi_nn_kernel_scalar_create(
                    graph, F32, &cell_clip );
            node_params[lstm_activation_param_num - _LSTMUINT_PARAM_NUM + 4] = vsi_nn_kernel_scalar_create(
                    graph, F32, &forget_bias );
            /* Pass parameters to node. */
            status  = vsi_nn_kernel_node_pass_param( node, node_params, lstm_activation_param_num );
            vsi_nn_kernel_scalar_release( &node_params[lstm_activation_param_num - _LSTMUINT_PARAM_NUM] );
            vsi_nn_kernel_scalar_release( &node_params[lstm_activation_param_num - _LSTMUINT_PARAM_NUM + 1] );
            vsi_nn_kernel_scalar_release( &node_params[lstm_activation_param_num - _LSTMUINT_PARAM_NUM + 2] );
            vsi_nn_kernel_scalar_release( &node_params[lstm_activation_param_num - _LSTMUINT_PARAM_NUM + 3] );
            vsi_nn_kernel_scalar_release( &node_params[lstm_activation_param_num - _LSTMUINT_PARAM_NUM + 4] );
        }
    }

    return node;

} /* _setup() */

__END_DECLS

REGISTER_BACKEND_EVIS( lstmunit_activation, _setup )

